<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Insert title here</title>
	<link rel="stylesheet" href="/miwawa/resources/lib/bootstrap/3.3.5/css/bootstrap.min.css" >
	<link rel="stylesheet" href="/miwawa/resources/lib/bootstrap/extends/bootstrap-fileinput/4.3.1/css/fileinput.min.css" >
</head>
<body>

	要导入的sheet索引: <input type="text" name="sheet" id="sheet" class="form-control">
	<button type="button" class="btn btn-default" onclick="createUpload()">确定</button>
	
	<input type="file" name="file" id="file" style="display: none;">
	
	<script src="/miwawa/resources/lib/miwawa/1.0.2/js/jquery/jquery-1.11.3.min.js"></script>
	<script src="/miwawa/resources/lib/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script src="/miwawa/resources/lib/bootstrap/extends/bootstrap-fileinput/4.3.1/js/fileinput.min.js"></script>
	<script src="/miwawa/resources/lib/bootstrap/extends/bootstrap-fileinput/4.3.1/js/locale/fileinput_locale_zh.js"></script>
	<script src="/miwawa/resources/lib/bootstrap/extends/bootstrap-notify/3.1.5/js/bootstrap-notify.min.js"></script>
	
	<script type="text/javascript">
	
		function createUpload(){
			if($("#sheet").val() == "" || $("#sheet").val() == undefined){
				alert("输入要导入的sheet索引");
			}else if($("#sheet").val() != "0" && $("#sheet").val() != "1" && $("#sheet").val() != "2"){
				alert("索引只能是0、1、2");
			}else{
				$("#file").show();
				
				$("#file").fileinput({ language: 'zh', uploadUrl:"/miwawa/file/import/"+$("#sheet").val() });
				
				$('#file').on('fileuploaded', function(event, data, previewId, index) {
			    if(data && data.response && data.response.success){
			    	jQuery.notify({
							message: data.response.success,
							icon: 'glyphicon glyphicon-ok'
						},{
							placement: {from: "top", align:"center"},
							z_index: 2031,
							type: 'success'
						});
			    }
				});
			}
		}
		
	</script>
</body>
</html>